﻿using System;
using Common.Logging;
using Seasar.Framework.Container;
using Seasar.Framework.Container.Factory;

namespace Mayfair.Core.Common.DI
{
    public class Seasar : AbstractDIContainer
    {
        private const string PATH = "./Example.dicon";
        private IS2Container container;
        private static ILog log = LogManager.GetLogger(typeof(Seasar));

        public Seasar()
        {
            container = S2ContainerFactory.Create(PATH);
            container.Init();
        }

        public override T GetObject<T>(Object key)
        {
            log.Debug("Object you got is : " + (string)key);
            return (T)container.GetComponent(key);
        }
    }

    #region "テスト用クラス"

    public class ISampleImpl : ISample
    {
        public ISampleImpl() { }

        #region ISample メンバ

        public string GetMessage()
        {
            return "You Got Me.";
        }

        #endregion
    }

    public interface ISample
    {
        string GetMessage();
    }

    #endregion
}